package com.parenting.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.parenting.response.*;
import com.parenting.sevice.ReportService;
import com.parenting.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 投诉 前端控制器
 * </p>
 *
 * @author wsx
 * @since 2021年10月22日
 */
@RestController
@RequestMapping("/report")
@Api(value = "Report", tags = "内容举报通知")
@Slf4j
public class ReportController {

    @Autowired
    private  ReportService reportService;

    @ApiOperation(value = "内容举报集合（后端使用）")
    @GetMapping("/reportList/{current}/{size}/{type}")
    public Result<ReportVO> reportList(@ApiParam(name = "current", value = "页码", required = true)
                                         @PathVariable("current") @NotNull(message = "页码不能为空") Integer current,
                                         @ApiParam(name = "size", value = "每页显示多少条", required = true)
                                         @PathVariable("size") @NotNull(message = "每页显示多少条不能为空") Integer size,
                                         @ApiParam(name = "type", value = "搜索类型 0:全部 1:待审批 2:已审批 3:已拒绝", required = true)
                                         @PathVariable("type") @NotNull(message = "搜索类型") Integer type) {
        return reportService.reportList(current, size, type);
    }



    @ApiOperation(value = "用户举报集合（后端使用）")
    @GetMapping("/reportUserList/{current}/{size}/{type}")
    public Result<ReportVO> reportUserList(@ApiParam(name = "current", value = "页码", required = true)
                                             @PathVariable("current") @NotNull(message = "页码不能为空") Integer current,
                                             @ApiParam(name = "size", value = "每页显示多少条", required = true)
                                             @PathVariable("size") @NotNull(message = "每页显示多少条不能为空") Integer size,
                                             @ApiParam(name = "type", value = "搜索类型 0:全部 1:待审批 2:已审批 3:已拒绝", required = true)
                                             @PathVariable("type") @NotNull(message = "搜索类型") Integer type) {
        return reportService.reportUserList(current, size, type);
    }


    @ApiOperation(value = "获得举报详情")
    @GetMapping("/reportInfo/{id}")
    public Result<PlazaInfo2ReplyVO> reportInfo(@ApiParam(name = "id", value = "举报的ID", required = true)
                                             @PathVariable("id") @NotNull(message = "id") Integer id) {
        log.info("================"+ id);
        return reportService.reportInfo(id);
    }


    @ApiOperation(value = "后端管理员审核举报操作")
    @PutMapping("/checkReportInfo")
    public Result checkReportInfo(@RequestBody @Validated CheckReportVO checkReportVO) {
        return reportService.checkReportInfo(checkReportVO);
    }

}
